package com.ftg.learn.controller;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ftg.learn.entity.User;
import com.ftg.learn.service.IUserService;
import com.ftg.learn.service.impl.UserServiceImpl;
import com.ftg.learn.util.BaseController;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.swing.text.html.parser.Entity;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huye
 * @since 2022-03-11
 */
@RestController
@RequestMapping("/water/user")
@Api(tags = "用户管理系统")
@CrossOrigin(origins = "http://26.198.126.55",
        allowedHeaders = "*",
        methods = {RequestMethod.GET,RequestMethod.POST,RequestMethod.DELETE,RequestMethod.PUT})



public class UserController extends BaseController<User,IUserService> {


    /**
     * 登陆功能
     * @param uaccount  用户名
     * @param password  密码
     * @return  map
     */
    @PostMapping("/login")
    public Map<String,Object> login(String uaccount, String password){

        return super.service.checkUser(uaccount,password);
    }

    /**
     * 添加功能  密码加密
     * @param e  用户信息
     * @return
     */
    @PostMapping("/saveForPassword")
    public boolean saveE(@RequestBody User e){
        return super.service.saveForPassword(e);
    }

    /**
     * 冻结
     * @param id  哪个账号
     * @param num 冻结  解冻
     * @return
     */
    @PutMapping("/updateIce/{id}/{num}")
    public boolean updateIce(@PathVariable("id") int id,@PathVariable("num") int num){
        return super.service.updateIce(id,num);
    }

    @PutMapping("/updateUserInfo")
    public boolean updateUserInfo(Long uid,String uaccount,String uname){
        return super.service.updateUserInfo(uid,uaccount,uname);
    }

    @PutMapping("/resetPassword")
    public boolean resetPassword(Long uid){
        return super.service.resetPassword(uid);
    }

}
//
//    @GetMapping("/show")
//   public List<User> showUser(){
//       return userService.list();
//   }
//
//    @DeleteMapping("/del/{id}")
//   public boolean delUser(@PathVariable int id){
//        return userService.removeById(id);
//   }
//
//   @PostMapping("/save")
//   public boolean saveUser(@RequestParam User user){
//        return  userService.save(user);
//   }
//    @PutMapping("/update")
//   public boolean  updateUser( @RequestParam User user){
//    return userService.updateById(user);
//   }
//
//
//}
